<?php 
$this->assign('button_save_template','<a href="javascript:void(0)" class="btn btn-sm btn-info" onclick="ShowModel();"><i class="fa fa-fw fa-plus"></i> NEW TEMPLATE</a>');
$this->Html->css(array('font', 'app.v2'), array('inline' => false));
$this->Html->script(array('app.v2', 'fuelux/fuelux', 'underscore-min', 'datatables/jquery.dataTables.min'), array('inline' => false));
?>
<section id="content">
	<section class="main padder">
		<div class="clearfix">
			<h4><i class="fa fa-table"></i>Table</h4>
		</div>
		<div class="row">
			<div class="col-lg-6">
				<section class="panel">
					<header class="panel-heading"><span class="label bg-danger pull-right">4 left</span> Tasks </header>
					<div>
						<table class="table table-striped m-b-none text-small">
							<thead>
								<tr>
									<th>Progress</th>
									<th>Item</th>
									<th width="70"></th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>
										<div class="progress progress-small progress-striped active m-t-mini m-b-none">
											<div class="progress-bar progress-bar-success" data-toggle="tooltip" data-original-title="80%" style="width: 80%"></div>
										</div>
									</td>
									<td>App prototype design</td>
									<td class="text-right">
										<div class="btn-group"><a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-pencil"></i></a>
											<ul class="dropdown-menu pull-right">
												<li><a href="#">Action</a></li>
												<li><a href="#">Another action</a></li>
												<li><a href="#">Something else here</a></li>
												<li class="divider"></li>
												<li><a href="#">Separated link</a></li>
											</ul>
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="progress progress-mini m-t-mini m-b-none">
											<div class="progress-bar progress-bar-info" data-toggle="tooltip" data-original-title="40%" style="width: 40%"></div>
										</div>
									</td>
									<td>Design documents</td>
									<td class="text-right">
										<div class="btn-group"><a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-pencil"></i></a>
											<ul class="dropdown-menu pull-right">
												<li><a href="#">Action</a></li>
												<li><a href="#">Another action</a></li>
												<li><a href="#">Something else here</a></li>
												<li class="divider"></li>
												<li><a href="#">Separated link</a></li>
											</ul>
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="progress progress-mini m-t-mini m-b-none">
											<div class="progress-bar progress-bar-warning" data-toggle="tooltip" data-original-title="20%" style="width: 20%"></div>
										</div>
									</td>
									<td>UI toolkit</td>
									<td class="text-right">
										<div class="btn-group"><a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-pencil"></i></a>
											<ul class="dropdown-menu pull-right">
												<li><a href="#">Action</a></li>
												<li><a href="#">Another action</a></li>
												<li><a href="#">Something else here</a></li>
												<li class="divider"></li>
												<li><a href="#">Separated link</a></li>
											</ul>
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="progress progress-mini m-t-mini m-b-none">
											<div class="progress-bar progress-bar-danger" data-toggle="tooltip" data-original-title="15%" style="width: 15%"></div>
										</div>
									</td>
									<td>Testing</td>
									<td class="text-right">
										<div class="btn-group"><a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-pencil"></i></a>
											<ul class="dropdown-menu pull-right">
												<li><a href="#">Action</a></li>
												<li><a href="#">Another action</a></li>
												<li><a href="#">Something else here</a></li>
												<li class="divider"></li>
												<li><a href="#">Separated link</a></li>
											</ul>
										</div>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</section>
			</div>
			<div class="col-lg-6">
				<section class="panel">
					<header class="panel-heading">Stats</header>
					<div>
						<table class="table table-striped m-b-none text-small">
							<thead>
								<tr>
									<th>Graph</th>
									<th>Item</th>
									<th width="70"></th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>
										<div class="sparkline" data-bar-color="#5cb85c" data-type="bar" data-height="19">
											<!--20,10,15,21,12,5,21,30,24,15,8,19-->
										</div>
									</td>
									<td>App downloads</td>
									<td class="text-success"><i class="fa fa-level-up"></i>40% </td>
								</tr>
								<tr>
									<td>
										<div class="sparkline" data-bar-color="#61a1e1" data-type="bar" data-height="19">
											<!--,5,21,30,24,15,8,19,20,10,15,21,12-->
										</div>
									</td>
									<td>Social connection</td>
									<td class="text-success"><i class="fa fa-level-up"></i>20% </td>
								</tr>
								<tr>
									<td>
										<div class="sparkline" data-bar-color="#999900" data-type="bar" data-height="19">
											<!--200,400,500,100,90,1200,1500,1000,800,500,80,50-->
										</div>
									</td>
									<td>Revenue</td>
									<td class="text-warning"><i class="fa fa-level-down"></i>5% </td>
								</tr>
								<tr>
									<td>
										<div class="sparkline" data-bar-color="#ff5f5f" data-type="bar" data-height="19">
											<!--15,21,30,24,15,8,19,20,10,15,21,12-->
										</div>
									</td>
									<td>Customer increase</td>
									<td class="text-danger"><i class="fa fa-level-down"></i>20% </td>
								</tr>
							</tbody>
						</table>
					</div>
				</section>
			</div>
		</div>
		<div class="row">
			<div class="col-lg-12">
				<section class="panel">
					<header class="panel-heading"><?php echo __('Customers'); ?></header>
					<div class="panel-body">
						<div class="row text-small">
							<div class="col-sm-4 m-b-mini">
								<!--
								<select class="input-sm inline form-control" style="width: 130px">
									<option value="0">Bulk action</option>
									<option value="1">Delete selected</option>
									<option value="2">Bulk edit</option>
									<option value="3">Export</option>
								</select>
								-->
								<?php echo $this->Html->link(__('New Customers'), array('action' => 'customers_add'), array('class' => 'btn btn-info')); ?>
							</div>
							<div class="col-sm-4 m-b-mini">
								<!--
								<div class="btn-group" data-toggle="buttons">
									<label class="btn btn-sm btn-white active">
										<input type="radio" name="options" id="option1">
										Day </label>
									<label class="btn btn-sm btn-white">
										<input type="radio" name="options" id="option2">
										Week </label>
									<label class="btn btn-sm btn-white">
										<input type="radio" name="options" id="option2">
										Month </label>
								</div>
								-->
							</div>
							<div class="col-sm-4">
								<div class="input-group">
									<input type="text" class="input-sm form-control" placeholder="Search">
									<span class="input-group-btn">
										<button class="btn btn-sm btn-white" type="button">Go!</button>
									</span></div>
							</div>
						</div>
					</div>
					<div class="table-responsive">
						<table class="table table-striped b-t text-small">
							<thead>
								<tr>
									<th width="20"><input type="checkbox"></th>
									<th><?php echo $this->Paginator->sort('id'); ?></th>
									<th><?php echo $this->Paginator->sort('username'); ?></th>
									<th><?php echo $this->Paginator->sort('email'); ?></th>
									<th><?php echo $this->Paginator->sort('description'); ?></th>
									<th><?php echo $this->Paginator->sort('subscription'); ?></th>
									<th><?php echo $this->Paginator->sort('end_date'); ?></th>
									<th><?php echo $this->Paginator->sort('payment'); ?></th>
									<th><?php echo $this->Paginator->sort('status'); ?></th>
									<th width="120"><?php echo __('Actions'); ?></th>
								</tr>
							</thead>
							<tbody>
							<?php foreach ($users as $user): ?>
								<tr>
									<td><input type="checkbox" name="post[]" value="2"></td>
									<td><?php echo h($user['User']['id']); ?></td>
									<td><?php echo $this->Html->link($user['User']['username'], array('action' => 'customers_view', $user['User']['id'])); ?></td>
									<td><?php echo h($user['User']['email']); ?></td>
									<td><?php echo h($user['User']['description']); ?></td>
									<td><?php echo h($user['Subscription'][count($user['Subscription'])-1]['name']);?>
									<td>
										<?php 
											date_default_timezone_set('Europe/Paris');
											$end_date = $user['Subscription'][count($user['Subscription'])-1]['SubscriptionsUser']['end_date'];
											$current_date = strtotime(date('d-m-Y'));
											$end_date = strtotime($end_date);
											if($end_date <= $current_date){
												echo "<span class='label bg-danger'>Expired</span>";
												echo "<a href='javascript:void(0)' onclick='Upgrade({$user['User']['id']})'> Upgrade Now </a>";
											} else {
												echo date('d-m-Y', $end_date);
											}
										?>
									<td><?php echo h($user['Subscription'][count($user['Subscription'])-1]['SubscriptionsUser']['payment']);?>
									<td><?php echo h($user['User']['status']); ?></td>
									<td>
										<?php echo $this->Html->link('<i class="fa fa-bolt fa-lg"></i>', array('action' => 'customers_security', $user['User']['id']), array('escape' => false, 'data-toggle' => 'tooltip', 'data-placement' => 'top', 'data-original-title' => 'Security')); ?>
										&nbsp;&nbsp;&nbsp;
										<?php echo $this->Html->link('<i class="fa fa-wrench fa-lg"></i>', array('action' => 'customers_edit', $user['User']['id']), array('escape' => false, 'data-toggle' => 'tooltip', 'data-placement' => 'top', 'data-original-title' => 'Edit')); ?>
										&nbsp;&nbsp;&nbsp;
										<?php echo $this->Html->link('<i class="fa fa-times fa-lg"></i>', array('action' => 'customers_delete', $user['User']['id']),array('escape' => false, 'data-toggle' => 'tooltip', 'data-placement' => 'top', 'data-original-title' => 'Delete'), __('Are you sure you want to delete # %s?', $user['User']['id'])); ?>
									</td>
								</tr>
							<?php endforeach; ?>
							</tbody>
						</table>
					</div>
					<footer class="panel-footer">
						<div class="row">
							<div class="col-sm-4 hidden-xs">
								<select class="input-sm inline form-control" style="width: 130px">
									<option value="0">Bulk action</option>
									<option value="1">Delete selected</option>
									<option value="2">Bulk edit</option>
									<option value="3">Export</option>
								</select>
								<button class="btn btn-sm btn-white" style="margin-top: -4px;">Apply</button>
							</div>
							<div class="col-sm-3 text-center">
								<small class="text-muted inline m-t-small m-b-small">
									<?php
										echo $this->Paginator->counter(array(
										'format' => __('Page {:page} of {:pages}, showing {:current} records out of{:count} total, starting on record {:start}, ending on {:end}')));
									?>
								</small>
							</div>
							<div class="col-sm-5 text-right text-center-sm">
								<!--
								<ul class="pagination pagination-small m-t-none m-b-none">
									<li><a href="#"><i class="fa fa-chevron-left"></i></a></li>
									<li><a href="#">1</a></li>
									<li><a href="#">2</a></li>
									<li><a href="#">3</a></li>
									<li><a href="#">4</a></li>
									<li><a href="#">5</a></li>
									<li><a href="#"><i class="fa fa-chevron-right"></i></a></li>
								</ul>
								-->
								<?php
									echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'btn btn-sm btn-white disabled'));
									echo $this->Paginator->numbers(array('separator' => ''));
									echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'btn btn-sm btn-white', 'style' => 'margin-left:4px'));
								?>
							</div>
						</div>
					</footer>
				</section>
			</div>
		</div>
	</section>
</section>